home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
wings
/
w2_src
/
pd_menu.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-16
|
4KB
|
154 lines
#define PD_MENU
#include <egb.h>
#include <mos.h>
#include <string.h>
#include <msdos.cf>
#include "define.h"
#include "module.h"
#include "extend.h"
#include "pd_menu.h"
#include "font_sub.h"
// プルダウンメニュー用拡張関数
#define BG_COLOR 8
#define ITEM_ON 8
#define ITEM_OFF 4
// プルダウンメニューのアイテムアドレスを計算する
void PDM_make_item_adress( struct PD_menu *menu, int *adr )
{
int i;
for( i=0;i<=menu->n-1;i++ ){
*( adr + (i*4)+0 ) = menu->item.x[ i ] = menu->x+6;
*( adr + (i*4)+1 ) = menu->item.y[ i ] = menu->y+4+(i*16);
*( adr + (i*4)+2 ) = menu->x + 6 + ( menu->len * 6 ) - 1;
*( adr + (i*4)+3 ) = menu->y + 4 + ( i * 16 ) + 15;
}
// 終端ターミネータ
*( adr + menu->n*4+0 ) = 0;
*( adr + menu->n*4+1 ) = 0;
*( adr + menu->n*4+2 ) = 0;
*( adr + menu->n*4+3 ) = 0;
return;
}
// プルダウンメニューを表示する
void PDM_display
( char *egbwork, char *strptn, struct PD_menu *menu, int *flag, int n )
{
int i, x, y, x1, y1, x2, y2, PAGE, col[ ] = { ITEM_OFF, ITEM_ON };
UINT egb_sel;
egb_sel = getds( );
PAGE = ( EGB_getWritePage( egbwork, egb_sel ) ) ? PAGE_1 : PAGE_0;
x1 = menu->x;
y1 = menu->y;
x2 = menu->x + ( menu->len * 6 ) + 11;
y2 = menu->y + ( menu->n * 16 ) + 7;
getimage( egbwork, x1, y1, x2, y2, n );
box( egbwork, x1 , y1 , x2 , y2 , BG_COLOR );
box( egbwork, x1+1, y1+1, x2-3, y2-3, 15 );
for( i=0;i<=menu->n-1;i++ ){
x = menu->item.x[ i ];
y = menu->item.y[ i ]+2;
font_ank_col( col[ *( flag + i ) ], 15 );
font_kan_col( col[ *( flag + i ) ], 15 );
font_mix( strptn, PAGE, POS( x, y ), menu->item.str[ i ], 0 );
}
return;
}
// プルダウンメニューを消去する
void PDM_erase( char *egbwork, struct PD_menu *menu, int n )
{
int x1, y1, x2, y2;
x1 = menu->x;
y1 = menu->y;
x2 = menu->x + ( menu->len * 6 ) + 11;
y2 = menu->y + ( menu->n * 16 ) + 7;
putimage( egbwork, x1, y1, x2, y2, n );
return;
}
// プルダウンメニューの押された番号を返す
int PDM_get_item_adress( int *adr, int x, int y )
{
int i = 0;
while( *( adr + i )+*( adr + i+1 )+*( adr + i+2 )+*( adr + i+3 ) ){
if( cmp( x, *( adr + i ), *( adr + i+2 ) )
&& cmp( y, *( adr + i+1 ), *( adr + i+3 ) ) )
return( i/4 );
i += 4;
}
return( -1 );
}
// プルダウンメニューのタイトルを表示
void PDM_display_title( char *egbwork, char *strptn, struct PD_menu *menu )
{
int len, PAGE;
UINT egb_sel;
egb_sel = getds( );
PAGE = ( EGB_getWritePage( egbwork, egb_sel ) ) ? PAGE_1 : PAGE_0;
strcat( menu->title, " ▼" );
len = strlen( menu->title ) + 4;
box( egbwork, menu->x, 0, menu->x+len*6-1, 19, BG_COLOR );
button_off( egbwork, menu->x, 0, menu->x+len*6-1, 19 );
font_ank_col( 15, BG_COLOR );
font_kan_col( 15, BG_COLOR );
font_mix( strptn, PAGE, POS( menu->x+12, 4 ), menu->title, 0 );
return;
}
// プルダウンメニューのタイトルボタンをON
void PDM_title_on( char *egbwork, struct PD_menu *menu )
{
int len;
len = strlen( menu->title ) + 4;
button_on( egbwork, menu->x, 0, menu->x+len*6-1, 19 );
}
// プルダウンメニューのタイトルボタンをOFF
void PDM_title_off( char *egbwork, struct PD_menu *menu )
{
int len;
len = strlen( menu->title ) + 4;
button_off( egbwork, menu->x, 0, menu->x+len*6-1, 19 );
}
// プルダウンメニューのアイテムをクリック
void
PDM_item_clic( char *egbwork, char *strptn, struct PD_menu *menu, int n )
{
int pdm_x, pdm_y, PAGE;
UINT egb_sel;
egb_sel = getds( );
PAGE = ( EGB_getWritePage( egbwork, egb_sel ) ) ? PAGE_1 : PAGE_0;
MOS_sleep;
pdm_x = menu->item.x[ n ];
pdm_y = menu->item.y[ n ]+2;
font_ank_col( 15, BG_COLOR );
font_kan_col( 15, BG_COLOR );
font_mix( strptn, PAGE, POS( pdm_x, pdm_y ), menu->item.str[ n ], 0 );
mos_loop( 1 );
sleep( 10 );
MOS_awake;
}